package com.hdu.executor;

import java.math.BigDecimal;

public class CompareHelper {

    public static boolean compare(OpCode opCode, BigDecimal paramValue, BigDecimal thresholdValue) {
        switch (opCode) {
            case EQ:
                return paramValue.compareTo(thresholdValue) == 0;
            case NEQ:
                return paramValue.compareTo(thresholdValue) != 0;
            case GT:
                return paramValue.compareTo(thresholdValue) > 0;
            case LT:
                return paramValue.compareTo(thresholdValue) < 0;
            case GTE:
                return paramValue.compareTo(thresholdValue) >= 0;
            case LTE:
                return paramValue.compareTo(thresholdValue) <= 0;
            default:
                throw new IllegalArgumentException("不支持的运算符");
        }
    }
}
